<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * Smarty {restaurant_type_1} function plugin
 * @param array|null $params
 * @param Smarty $smarty
 */
function smarty_function_restaurant_type_1($params, $smarty) {
    if (!isset($params)) {
        return ;
    }

    if (isset($params['limit'])) {
        $limit = $params['limit'];
    } else {
        $limit = 4;
    }

    $filters = array('limit' => $limit);
    $smarty->CI->load->model('restaurant/restaurant_model');
    $data = $smarty->CI->restaurant_model->get_restaurants($filters);
    if (!$data) {
        return '';
    }

    $html = '';
    foreach ($data as $item) {
        $html .= "<div class='home-newplace-subitembig'>
                <div>
                    <a href='{$item[link]}'>
                    <img src='{$item[image2]}' alt='{$item[name]}' title='{$item[name]}' width='300' height='187'></a>
                </div>
                <h3 class='newplace-bigname'><a href='{$item[link]}'>{$item[name]}</a></h3>
                <div style='padding: 5px 0; overflow: hidden; color: #555;'>
                    <p>
                        {$item[address]}, {$item[pref_name]}
                    </p>
                </div>";
        if ($params['show_intro'] == true) {
            $html .= "<p style='font-size: 11px; color: #777; padding-bottom: 3px;'>
                     {$item[introtext]}
                    </p>";
        }

        $html .= "
                <div class='items-stats2'>
                    <a href='javascript:void(0)' class='restaurant-reviews-link stats-review' resid='8436' title='bình luận'>16 bình luận</a>
                </div>
            </div>";
    }
    return $html;
}
